package hedspi.k55.sm.view;

import hedspi.k55.sm.R;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ArrayAdapter;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;

public class OverviewActivity extends SherlockActivity implements Iview,
		ActionBar.OnNavigationListener {
	String[] menu;
	String[] list_source;
	String[] list_destination;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setTheme(THEME);
		setContentView(R.layout.overview_activity);

		Context context = getSupportActionBar().getThemedContext();

		ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(
				context, R.array.menu_list, R.layout.menu_list_item);
		list.setDropDownViewResource(R.layout.menu_dropdown_list_item);
		getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
		getSupportActionBar().setListNavigationCallbacks(list, this);
		getSupportActionBar().setDisplayHomeAsUpEnabled(true);
		getSupportActionBar().setDisplayShowTitleEnabled(false);
		getSupportActionBar().setSelectedNavigationItem(0);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		boolean isLight = THEME == R.style.Theme_Sherlock_Light;
		menu.add(R.string.action_bar_search)
				.setOnMenuItemClickListener(
						new MenuItem.OnMenuItemClickListener() {

							@Override
							public boolean onMenuItemClick(MenuItem item) {
								return false;
							}
						})
				.setIcon(
						isLight ? R.drawable.title_btn_add_dark
								: R.drawable.title_btn_add)
				.setActionView(R.layout.collapsiable_search)
				.setShowAsAction(
						MenuItem.SHOW_AS_ACTION_ALWAYS
								| MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onNavigationItemSelected(int itemPosition, long itemId) {
		switch (itemPosition) {
		case 0:
			break;
		case 1:
			Intent stock = new Intent(OverviewActivity.this,
					PortfolioActivity.class);

			startActivity(stock);
			finish();
			break;
		case 2:
			break;
		default:
			break;
		}
		return true;
	}
}
